package com.gmzg.gmzgnews.news.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.gmzg.gmzgnews.news.fragments.BaseFragment;

import java.util.List;

/**
 * Created by Jasen on 2016 2016/11/1.10:48
 * Email:1142803753@qq.com
 * weixin: aserbao
 */

public class CommonFragmentPagerAdapter extends FragmentPagerAdapter {

    private List<BaseFragment> mFragments;

    public CommonFragmentPagerAdapter(FragmentManager fm, List<BaseFragment> fragments) {
        super(fm);
        mFragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        int ret = 0;
        if (mFragments != null) {
            ret = mFragments.size();
        }
        return ret;
    }
    @Override
    public CharSequence getPageTitle(int position) {
        return mFragments.get(position).getFragmentTitle();
    }
}
